import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class RotateImageView extends StatefulWidget {
  @override
  _RotateImageViewState createState() => _RotateImageViewState();
}

class _RotateImageViewState extends State<RotateImageView>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  late Animation<double> _animation;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: 2), // 动画持续时间
      vsync: this,
    )..repeat(); // 循环动画

    _animation = Tween<double>(begin: 0, end: 2 * 3.14159) // 旋转一圈
        .animate(CurvedAnimation(
      parent: _controller,
      curve: Curves.linear, // 线性动画
    ));
  }

  @override
  void dispose() {
    _controller.dispose(); // 释放控制器
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Center(
        child: AnimatedBuilder(
          animation: _animation,
          builder: (context, child) {
            return Transform.rotate(
              angle: _animation.value, // 旋转角度
              child: Image.asset(
                'assets/images/Frame@2x (1).png',
                width: 52.w,
                height: 52.w,
              ), // 替换为您的图片路径
            );
          },
        ),
      ),
    );
  }
} 